<?
function show_chapters($chapters){
    echo "<ul id=\"menu\">";
    foreach($chapters as $chapter){
        echo "<li><a href=\"{$chapter['href']}\">{$chapter['name']}</a>";
        if(isset($chapter['subchapters']))
            echo show_chapters($chapter['subchapters']);    
        echo "</li>";
    }
    echo "</ul>";
}

show_chapters($chapters); 

?>